#!/bin/bash
if [ ! -d toolchain ]; then
    echo "Decompressing Toolchain..."
    tar xvf toolchain.tar.xz
    if [ $? != 0 ]; then
        echo Please download toolchain.tar.xz
        exit 1
    fi
fi

export PATH=`pwd`/toolchain/Sourcery_G++_Lite/bin:`pwd`/toolchain/arc-4.8-amlogic-20130904-r2/bin:${PATH}
#make distclean
make clean
make m8b_m201C_512M_config
make -j`nproc` all
#echo "********************"
#echo "tools/convert --soc m8b -s build/firmware.bin -i build/u-boot-comp.bin -o build/u-boot.bin"
echo "***Firmware Built***"
